package org.example.Thread01;

public class Test06 {
    public static void main(String[] args) throws InterruptedException {
        Object locker=new Object();
        Thread t1 = new Thread(()->{
            synchronized (locker){
                System.out.println("t1线程等待开始...");
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t1线程等待结束...");
            }
        });
        Thread t2 = new Thread(()->{
            synchronized (locker){
                System.out.println("t2线程等待开始...");
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t2线程等待结束...");
            }
        });
        Thread t3 = new Thread(()->{
            synchronized (locker){
                System.out.println("t3开始唤醒操作...");
                locker.notifyAll();
                System.out.println("唤醒结束...");
            }
        });
        t1.start();
        t2.start();
        Thread.sleep(1000);
        t3.start();
    }
}
